<template>
    <div class="bigimg" @click="Notificationpage(id)">
      <div style="flex:1;margin:auto;">
        <div class="dain" v-if="type=='未查看'"></div>
        <img
          class="data-img"
          v-if="type==0"
          src="https://hterobot-kimage.oss-cn-qingdao.aliyuncs.com/images1/message_email.png"
          alt
        />
        <img
          class="data-img"
         v-else
          src="https://hterobot-kimage.oss-cn-qingdao.aliyuncs.com/images1/message_system.png"
          alt
        />
      </div>
      <div style="flex:5">
        <div style="display:flex;margin-bottom:20rpx;">
          <span style="flex:1">{{title}}</span>
          <span>{{alltime}}</span>
        </div>
        <!-- <p class="txte" v-html="commentsh"></p> -->
      </div>
    </div>
</template>
<script>
export default {
  data() {
    return {
        // xianshi:'未查看'
    };
  },
  props: {
    id: Number,
    type: String,
    title: String,
    text: String,
    time: Number
  },
  mounted() {
    this.start();
  },
  computed:{
    alltime() {
      const fortime = Date.parse(new Date()) - 24 * 60 * 60 * 1000;
      const fonty= new Date(fortime).getFullYear() +"-" +(new Date(fortime).getMonth() + 1) +"-" +new Date(fortime).getDate()
      const  jhg= new Date().getFullYear() +"-" +(new Date().getMonth() + 1) +"-" +new Date().getDate()
      const timeij =new Date(this.time).getFullYear() +"-" +(new Date(this.time).getMonth() + 1) +"-" +new Date(this.time).getDate()
      if(jhg==timeij){
        return '今天'
      }else if(fonty==timeij){
        return '昨天'
      }else{
        return timeij
      }
    },
  },
  methods: {
    Notificationpage(v){
      var that = this
      const schoolannouncementpushid =this.id
      const schoolstudentid =wx.getStorageSync("loginUserInfo").ID
 wx.request({
          url: that.$interfaces.Mailinformation+"/"+schoolannouncementpushid+"/"+schoolstudentid,
         method: "get",
         success: function(res) {
           const ID = res.data.ID
      const type = '已查看'
        wx.request({
          url: that.$interfaces.mailstatus+"/"+ID+"/"+type,
         method: "get",
         success: function(res) {
         }
        })
         }
 })
       wx.navigateTo({
        url: `../../pages/newNotice/main?id=${v}`
      });
    },
    start() {
    }
  }
};
</script>
<style>
.bigimg {
  display: flex;
  background-color: #fff;
  margin-bottom: 30rpx;
  padding: 27rpx;
}
.data-img {
  width: 100rpx;
  height: 100rpx;
}
.txte {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 14px;
  color: #888;
}
.dain{
  float: right;
  width: 16rpx;
  height: 16rpx;
  background-color: red;
  border-radius: 50%;
  margin-right: 25rpx;
  margin-top: 25rpx;
}
</style>
